import logging
import logging
import os
import time
from playwright.sync_api import sync_playwright, Page

logdir = "./logs"
if not os.path.isdir(logdir):
    os.mkdir(logdir)
logging.basicConfig(
    # filename="./logs/access.log",
    level=logging.INFO,
    format="%(asctime)s %(name)s %(levelname)s %(message)s",
    datefmt='%Y-%m-%d  %H:%M:%S %a'
)


class SuperClass:
    page = None  # type: Page
    log = None  # type: logging

    def __init__(self, page, logging):
        self.page = page
        self.log = logging

    def waitForSomeTime(self):
        time.sleep(2)

    def resetToStartPage(self):
        """
        重置页面，从这里为七点
        :return:
        """
        page = self.page
        self.log.info("resetToStart page")
        # Click span:has-text("欢迎您，管理员")
        page.click("span:has-text(\"欢迎您，管理员\")")
        # Click text=个人中心
        page.click("text=个人中心")
        # assert page.url == "http://localhost:3000/account/center"
